package com.hsh.maoduo.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;

import java.math.BigDecimal;

@Slf4j
public class DataUtil {

    /**
     * 判断 bigStr 中是否包含 smallStr
     * @param bigStr
     * @param smallStr
     * @return
     */
    public static boolean include(String bigStr, String smallStr) {
        if (bigStr == null || Strings.isBlank(smallStr)) {
            return false;
        }
        return bigStr.indexOf(smallStr) >= 0;
    }

    public static boolean isNotBlankOrZero(BigDecimal bigDecimal) {
        return bigDecimal != null && BigDecimal.ZERO.compareTo(bigDecimal) != 0;
    }

    public static boolean isBlankOrZero(BigDecimal bigDecimal) {
        return bigDecimal == null || BigDecimal.ZERO.compareTo(bigDecimal) == 0;
    }


    public static String removeSpaceAndSymbols(String str) {
        if (Strings.isBlank(str)) {
            return str;
        }
        return str.replaceAll("\\s", "")
                .replaceAll(":", "")
                .replaceAll("·", "");
    }

    /**
     * 字符串转为数字
     * 不是整数返回-1
     *
     * @param str
     * @return res
     */
    public static int parseInt(String str) {
        int res = -1;
        try {
            res = Integer.parseInt(str);
        } catch (NumberFormatException e) {

        }
        return res;
    }

    public static void main(String[] args) {
        String trims = DataUtil.removeSpaceAndSymbols("广东省深圳市龙华区民治街道广东省深圳市龙华区潜龙·华城A区-5栋-1单元 (潜龙鑫茂A5栋外围商铺德佑店)");
        System.out.println(trims);
    }
}
